<?php 
    header('Content-Type:application/json');

    $t_name = $_POST['t_name'];//任务名称
    $pid=$_POST['p_id'];//所属项目id

    // 插入数据
     if(!isset($t_name)){
        echo(json_encode(['success'=>false,'msg'=>'请输入任务名称']));
     }else{
        $conn = mysqli_connect('127.0.0.1','root','123456','super','3306');
        if($conn){
            mysqli_query($conn,"SET NAMES utf8");
            $sq = "INSERT INTO project_detail(pid,t_name) VALUES('$pid','$t_name')";
            $result = mysqli_query($conn,$sq);
            
            if($result){                
                echo(json_encode(['success'=>true,'data'=>mysqli_insert_id($conn)]));
            }else{
                // $erro=mysqli_error();
                echo(json_encode(['success'=>false]));
            }
        }else{
            echo(json_encode(['success'=>false,'msg'=>'数据库连接失败！']));
        }
    }

 ?>